package com.innoking.docsys.logger.service.impl;

import com.innoking.docsys.log.module.LoggerVO;
import com.innoking.docsys.logger.dao.master.MasterLogUserLoginDao;
import com.innoking.docsys.logger.dto.LogDocDestroy;
import com.innoking.docsys.logger.service.LoggerCall;
import com.innoking.docsys.logger.utils.LoggerUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author sunq
 * 策略模式处理log业务
 */
public class LoggerEditCallImpl implements LoggerCall {

    @SuppressWarnings(value={"null"})
    public   RedisTemplate redisTemplate;

    @SuppressWarnings(value={"null"})
    public MasterLogUserLoginDao masterLogUserLoginDao;

    public LoggerEditCallImpl(RedisTemplate redis,MasterLogUserLoginDao dao) {
        this.redisTemplate=redis;
        this.masterLogUserLoginDao=dao;
    }
    @Override
    public void addLogger(LoggerVO vo) {

        redisTemplate.opsForList().leftPush(LoggerUtils.LOGGER_EDIT,vo);
        LogDocDestroy dto=new LogDocDestroy();
        BeanUtils.copyProperties(vo,dto,"targetContent");
        masterLogUserLoginDao.insertDocDestroyLog(dto);

    }
}